<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>

    <h:form id="game" styleClass="edit">
    
        <rich:panel>
            <f:facet name="header">#{gameHome.managed ? 'Edit' : 'Add'} Game</f:facet>




            <s:decorate id="crossLaneDecoration" template="layout/edit.xhtml">
                <ui:define name="label">crossLane</ui:define>
                <h:selectBooleanCheckbox id="crossLane"
                                   required="true"
                                      value="#{gameHome.instance.crossLane}"/>
            </s:decorate>


            <s:decorate id="dateDecoration" template="layout/edit.xhtml">
                <ui:define name="label">date</ui:define>
				<rich:calendar id="date" 
                          value="#{gameHome.instance.date}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="frameDetailsDecoration" template="layout/edit.xhtml">
                <ui:define name="label">frameDetails</ui:define>
                <h:inputTextarea id="frameDetails"
                               cols="80"
                               rows="3"
                              value="#{gameHome.instance.frameDetails}"/>
            </s:decorate>



            <s:decorate id="gameDetailLevelDecoration" template="layout/edit.xhtml">
                <ui:define name="label">gameDetailLevel</ui:define>
                <h:inputText id="gameDetailLevel"
                          value="#{gameHome.instance.gameDetailLevel}">
                    <a:support event="onblur" reRender="gameDetailLevelDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <s:decorate id="laneDecoration" template="layout/edit.xhtml">
                <ui:define name="label">lane</ui:define>
                <h:inputText id="lane"
                       required="true"
                          value="#{gameHome.instance.lane}">
                    <a:support event="onblur" reRender="laneDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="pinDetailsDecoration" template="layout/edit.xhtml">
                <ui:define name="label">pinDetails</ui:define>
                <h:inputTextarea id="pinDetails"
                               cols="80"
                               rows="3"
                              value="#{gameHome.instance.pinDetails}"/>
            </s:decorate>



            <s:decorate id="resultDecoration" template="layout/edit.xhtml">
                <ui:define name="label">result</ui:define>
                <h:inputText id="result"
                       required="true"
                          value="#{gameHome.instance.result}">
                    <a:support event="onblur" reRender="resultDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

        
            <div style="clear:both">
                <span class="required">*</span> 
                required fields
            </div>
            
        </rich:panel>
                
        <div class="actionButtons">

            <h:commandButton id="save" 
                          value="Save" 
                         action="#{gameHome.persist}"
                       disabled="#{!gameHome.wired}"
                       rendered="#{!gameHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="Save" 
                         action="#{gameHome.update}"
                       rendered="#{gameHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="Delete" 
                         action="#{gameHome.remove}"
                      immediate="true"
                       rendered="#{gameHome.managed}"/>
                    
            <s:button id="done" 
                   value="Done"
             propagation="end"
                    view="/Game.xhtml"
                rendered="#{gameHome.managed}"/>
                
            <s:button id="cancel" 
                   value="Cancel"
             propagation="end"
                    view="/#{empty gameFrom ? 'GameList' : gameFrom}.xhtml"
                rendered="#{!gameHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">
    
    <rich:tab label="alley">
    <div class="association" id="alleyParent">
    
        <h:outputText value="There is no alley associated with this game." 
                   rendered="#{gameHome.instance.alley == null}"/>
        
        <rich:dataTable var="alley" 
                   value="#{gameHome.instance.alley}" 
                rendered="#{gameHome.instance.alley != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="alleyTable">
            <h:column>
                <f:facet name="header">id</f:facet>
                #{alley.id}
            </h:column>
            <h:column>
                <f:facet name="header">description</f:facet>
                #{alley.description}
            </h:column>
            <h:column>
                <f:facet name="header">name</f:facet>
                #{alley.name}
            </h:column>
            <h:column>
                <f:facet name="header">numberOfLanes</f:facet>
                #{alley.numberOfLanes}
            </h:column>
            <h:column>
                <f:facet name="header">action</f:facet>
                <s:link view="/Alley.xhtml" 
                         id="viewalley" 
                      value="View" 
                propagation="none">
                    <f:param name="alleyId" 
                           value="#{alley.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="Select alley"
                       view="/AlleyList.xhtml">
                <f:param name="from" value="GameEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
    
    <rich:tab label="gameBlock">
    <div class="association" id="gameBlockParent">
    
        <h:outputText value="There is no gameBlock associated with this game." 
                   rendered="#{gameHome.instance.gameBlock == null}"/>
        
        <rich:dataTable var="gameBlock" 
                   value="#{gameHome.instance.gameBlock}" 
                rendered="#{gameHome.instance.gameBlock != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="gameBlockTable">
            <h:column>
                <f:facet name="header">id</f:facet>
                #{gameBlock.id}
            </h:column>
            <h:column>
                <f:facet name="header">average</f:facet>
                #{gameBlock.average}
            </h:column>
            <h:column>
                <f:facet name="header">description</f:facet>
                #{gameBlock.description}
            </h:column>
            <h:column>
                <f:facet name="header">onePinSparePercentage</f:facet>
                #{gameBlock.onePinSparePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">sparePercentage</f:facet>
                #{gameBlock.sparePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">strikePercentage</f:facet>
                #{gameBlock.strikePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">action</f:facet>
                <s:link view="/GameBlock.xhtml" 
                         id="viewgameBlock" 
                      value="View" 
                propagation="none">
                    <f:param name="gameBlockId" 
                           value="#{gameBlock.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="Select gameBlock"
                       view="/GameBlockList.xhtml">
                <f:param name="from" value="GameEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
    
    <rich:tab label="gameSet">
    <div class="association" id="gameSetParent">
    
        <h:outputText value="There is no gameSet associated with this game." 
                   rendered="#{gameHome.instance.gameSet == null}"/>
        
        <rich:dataTable var="gameSet" 
                   value="#{gameHome.instance.gameSet}" 
                rendered="#{gameHome.instance.gameSet != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="gameSetTable">
            <h:column>
                <f:facet name="header">id</f:facet>
                #{gameSet.id}
            </h:column>
            <h:column>
                <f:facet name="header">average</f:facet>
                #{gameSet.average}
            </h:column>
            <h:column>
                <f:facet name="header">description</f:facet>
                #{gameSet.description}
            </h:column>
            <h:column>
                <f:facet name="header">onePinSparePercentage</f:facet>
                #{gameSet.onePinSparePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">sparePercentage</f:facet>
                #{gameSet.sparePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">strikePercentage</f:facet>
                #{gameSet.strikePercentage}
            </h:column>
            <h:column>
                <f:facet name="header">action</f:facet>
                <s:link view="/GameSet.xhtml" 
                         id="viewgameSet" 
                      value="View" 
                propagation="none">
                    <f:param name="gameSetId" 
                           value="#{gameSet.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="Select gameSet"
                       view="/GameSetList.xhtml">
                <f:param name="from" value="GameEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
    
    <rich:tab label="player">
    <div class="association" id="playerParent">
    
        <h:outputText value="There is no player associated with this game." 
                   rendered="#{gameHome.instance.player == null}"/>
        
        <rich:dataTable var="player" 
                   value="#{gameHome.instance.player}" 
                rendered="#{gameHome.instance.player != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="playerTable">
            <h:column>
                <f:facet name="header">id</f:facet>
                #{player.id}
            </h:column>
            <h:column>
                <f:facet name="header">cbaId</f:facet>
                #{player.cbaId}
            </h:column>
            <h:column>
                <f:facet name="header">name</f:facet>
                #{player.name}
            </h:column>
            <h:column>
                <f:facet name="header">action</f:facet>
                <s:link view="/Player.xhtml" 
                         id="viewplayer" 
                      value="View" 
                propagation="none">
                    <f:param name="playerId" 
                           value="#{player.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="Select player"
                       view="/PlayerList.xhtml">
                <f:param name="from" value="GameEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
